<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of gradientMag</title>
  <meta name="keywords" content="gradientMag">
  <meta name="description" content="Compute gradient magnitude and orientation at each image location.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html channels -->
<h1>gradientMag
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Compute gradient magnitude and orientation at each image location.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [M,O] = gradientMag( I, channel, normRad, normConst, full ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Compute gradient magnitude and orientation at each image location.

 If input image has k&gt;1 channels and channel=0, keeps gradient with
 maximum magnitude (over all channels) at each location. Otherwise if
 channel is between 1 and k computes gradient for the given channel.
 If full==1 orientation is computed in [0,2*pi) else it is in [0,pi).

 If normRad&gt;0, normalization is performed by first computing S, a smoothed
 version of the gradient magnitude, then setting: M = M./(S + normConst).
 S is computed by S = convTri( M, normRad ).

 This code requires SSE2 to compile and run (most modern Intel and AMD
 processors support SSE2). Please see: http://en.wikipedia.org/wiki/SSE2.

 USAGE
  [M,O] = gradientMag( I, [channel], [normRad], [normConst], [full] )

 INPUTS
  I          - [hxwxk] input k channel single image
  channel    - [0] if&gt;0 color channel to use for gradient computation
  normRad    - [0] normalization radius (no normalization if 0)
  normConst  - [.005] normalization constant
  full       - [0] if true compute angles in [0,2*pi) else in [0,pi)

 OUTPUTS
  M          - [hxw] gradient magnitude at each location
  O          - [hxw] approximate gradient orientation modulo PI

 EXAMPLE
  I=rgbConvert(imread('peppers.png'),'gray');
  [Gx,Gy]=gradient2(I); M=sqrt(Gx.^2+Gy.^2); O=atan2(Gy,Gx);
  full=0; [M1,O1]=gradientMag(I,0,0,0,full);
  D=abs(M-M1); mean2(D), if(full), o=pi*2; else o=pi; end
  D=abs(O-O1); D(~M)=0; D(D&gt;o*.99)=o-D(D&gt;o*.99); mean2(abs(D))

 See also gradient, <a href="gradient2.html" class="code" title="function [Gx,Gy] = gradient2( I )">gradient2</a>, <a href="gradientHist.html" class="code" title="function H = gradientHist( M, O, varargin )">gradientHist</a>, <a href="convTri.html" class="code" title="function J = convTri( I, r, s, nomex )">convTri</a>

 Piotr's Computer Vision Matlab Toolbox      Version 3.23
 Copyright 2014 Piotr Dollar &amp; Ron Appel.  [pdollar-at-gmail.com]
 Licensed under the Simplified BSD License [see external/bsd.txt]</pre></div>





<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
